modernityfandomcom-20200215-history
User blog:VelvetClaw/How to mod a unit
thumb|Are you itching to insert crazy death robots into your game? then this guide is meant for you! Are you itching to insert teddy bears and crazy death robots into your game? or are you just peeved that BHG left a whole load of inconsistencies and ahistorical bull in your game? well then, this guide is meant for you! Modding a unit in Rise of Nations looks more difficult than it really seems. To be honest, the only issue involved may be in creating the renders and the tedium in the coding required, but overall it is actually a very fast process, and sometimes rewarding as well. This guide tries to go step by step in designing a model from scratch, from the creating of the graphics required for a new unit all the way to getting it to work in the game. We will first explain how graphics are created, and then go on to inserting the model into the game itself. To work with RoN, the following are required: *3ds Max 5.1, with Character Studio 3.4, and the Big Huge Exporter plugin (plugin only works for Win XP, 3ds Max 5.1 works with Windows XP and Windows 7 only - issues with certificate access have been found with Windows 10) OR *Blender (preferred version: latest) with Ryder25's BH3/BHA exporter plugin. Unless mentioned, this tutorial will assume that the reader has chosen to install 3ds Max 5.1, for reasons that will be made clear below. HOW DO GRAPHICS IN RISE OF NATIONS WORK? In Rise of Nations, units consist of two elements — the graphic files which allow a unit to appear and be animated in the game world, as well as coding which allows the unit to perform its functions in the game. WHAT FILES GOVERN A UNIT'S APPEARANCE? This is determined by the following: - a .bh3 model. This is the model for the sprite as it appears in your game, and will be stored in your /art folder; - .bha files, which governs unit animation, ie how the unit moves and so forth, which goes into the /art folder too; - a .tga file, which if not properly inserted causes the unit to appear white. This also goes into the same folder as above; and - entries in the unit_graphics.xml file under your/data folder. BUT HOW ON EARTH DO I GET''' IT TO WORK? There are several files which govern how a unit functions: - unitrules.xml, under your /data folder, will govern a unit's attributes, ie attack, movement speed, hitpoints, as well as graphics; and - craftrules.xml and balance.xml will govern the abilities of your unit. -anim_graphics.xml governs animations. Custom animations must be recorded here otherwise they won't work. - unit_graphics.xml determines the appearance and movements of the unit, and - typenames.xml and help.xml govern infobox data and the unit's name as it should appear in-game. Of these, however, we must pay utmost attention when modifying any .xml files in Rise of Nations - faulty coding at the least will leave units inoperable, and at worst crash your entire game. For this reason we strongly discourage overwriting any source files in ./data or ./art unless it is necessary, and to use FirstObject XML Editor to edit any .xml files. HOW MANY CUSTOM UNITS CAN I INSERT INTO RISE OF NATIONS? Sadly, the answer is none, because in reality the number of units is determined by the number of entries for each unit in Rise of Nations in the unitrules.xml file (for convenience, we will call each area where you can insert data for a new unit as a "slot"). Each slot is demarcated by the tagging '''... with the statistics of the unit (ie name, type, tactical parameters, etc) located within this tag. You can only create new units by "cannibalising" existing slots. In theory, there are roughly about 150 available unit slots to cannibalse. ENOUGH BABBLING! JUST SHOW ME HOW TO DO IT! Let's use an example from Age of Darkness. Suppose that I want to insert a new unit that I want to call "Panzerfaust", a custom infantryman which can fire rockets and is represented by two different sprites. How do I go about this? the answer is simple: Graphics The first thing I do is to get out the graphics for two different sprites. Generally, in Rise of Nations a unit by default needs at least 1 .tga file, and 1 .bh3 file (the model itself) as well as accompanying .bha files that govern the animation. For the purposes of this tutorial, we will have 1 .bh3 file, pfaust.bh3 and 2 .tga files, d_m44.tga and d_m45.tga. The .bh3 and .bha files for Rise of Nations can only be created if you have 3ds Max 5.1 and the Big Huge Exporter plugin produced by BHG. We will not cover this, there are many tutorials elsewhere on how to create your own 3d models using this program. Meanwhile, on to sprites. You must be asking, why do we need to create two sets of .tga files if we are just creating only one unit? this is because although I am only creating one unit, I want this unit to have a varied appearance, hence the need for two .bh3 files - one for each sprite. The bh3 files however are not enough on their own, so I must also have .tga files which form the "skin" of the unit. 400px|center In this screenshot, you can see what the .tga files look like when opened up in GIMP2.8.1 Remember that to create unit colour areas, you need to render parts of the model semi-transparent. Rise of Nations when in operation "wraps" the texture of the tga around the model as determined by the bh3 file. If we opened up the unit model file in 3ds Max and then used, say, d_m44.tga file as its skin, this is what it would look like: center|460px With these files ready, I will now put the .bh3 files into the ./art folder of my project directory, ./mods/Age of Darkness/art/Inf folder. 460px|center As you can see, I now have several files in my folder in addition to pfaust.bh3, and d_m44.tga and d_m45.tga. These are: *RPG-default.bha, RPG-idle.bha, RPG-idle2.bha and RPG-idle3.bha - governs unit animations when the unit is not doing anything, ie idle. *RPG-walk.bha, and RPG-run.bha - governs how the unit moves, ie walks. RPG-walk.bha is for when the unit moves slowly, and RPG-run.bha is for when the unit moves quickly, ie under the influence of a General's Forced March ability, or the Bantu civilisation's movement bonus. *RPG-fire.bha and RPG-fire - Copy.bha - governs unit attack animations, and *VC die1.bha and VC die2.bha - governs unit animations when it dies. I also have inserted another folder into my directory, ./mods/Age of Darkness/art/Skeletons which allows the use of custom skeletons — the bones that appear whenever a unit dies. Into this folder, I have also inserted another file, skelett.bh3 which will serve as the skeleton of this unit once it dies and decays. What about Blender? WARNING: Because the current plugin by ryder25 cannot support any more than 1 ammo node, 1 pivot node or 1 smoke node (RoN will not recognise them for some reason or the other) Blender is NOT recommended for multiturreted units or buildings. 3ds Max 5.1 (with Character Studio 3.4) is preferred. For Blender, First, *export your finished model as a 3ds model. Lay it aside. *Clean your scene and delete your model, then add the armature: Then, *Reimport your model back into Blender. *Scale your model back up by 10. Select the mesh and then select apply scale. *Set origin for both mesh and armature to coords (0,0,0) *Triangulate (if exported wit quads, there will be holes in the mesh) For the armature: *Use bones, and include the following bones: *root *ammo node 0 *(optional) smoke node 0, pivot node 0 *In the skin object, select the pose, and in the data tab, choose "rest position" instead of "pose position". Now when you export the bh3 model, the vertices should look correct in relation to the bones. If yiou are copying weights from a pre-existing model don't forget to Clean all weights once you are done. Finally, select the mesh object and export as BH3 To animate, import back the BH3 file, and then begin by posing it using conventional Blender techniques. Then, select the armature and export it as a BHA file. The rate of replay, at a speed of 30 FPS, is 2 frames per tick - so for example, if you have a animation that is set to 30 ticks, your bHA file should have a length of 60 frames, with the first and last frames preferbly set to 0 and 59 respectively. Some caveats *Always ensure that every vertex in your Blender model is assigned SOLELY to one vertex group, and one vertex group alone. *It might be more expedient to assign weights manually by creating as many vertex groups as necessary, and then assign or remove vertices as you see fit. *A single mesh in Blender may have no more than one Armature modifier. *Animations are 30FPS, and should begin at Frame 1, not Frame 0. *When animating, it is preferable to use a freshly imported model's armature, rather than an appended object. *Baking animations for BHAs is NOT advised, tests showed that files created from baked animations may cause your game to crash.file:armature_modifier.png The anim_graphics file Continued here. The unit_graphics file Continued here. *A ranged unit such as a tank or a horse archer needs a special node, "pivot node 0" embedded into its armature/skeleton. **A model created using 3ds Max 5 can have as many as three, from node_0 to node_2, but this is not possible if using Blender on Ryder25's node. **These are set by the RESTRICTIONS tag of your unit_graphics.x file. *A war elephant unit (see unitrles below) must have 5 different attack animations: **One static ranged attack anim **One moving ranged attack anim **Three close-order attack anims The unitrules file (TBC) Notes *Never (never, never, ever) have a unit upgrade from a base unit which you have already had another unit grafted to. *GRAFTed units should always have the same stats and tech level as their base unit from which they GRAFT.